package com.xmall.timer.service.impl;

import com.xmall.timer.dto.TimerTaskDto;
import com.xmall.timer.handler.ITimerTaskHandler;
import com.xmall.timer.manager.TimerTaskManager;
import com.xmall.timer.service.ICommonTimerTaskService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class CommonTimerTaskServiceImpl implements ICommonTimerTaskService {

    @Resource
    private TimerTaskManager timerTaskManager;

    /**
     * 执行任务
     */
    @Override
    public void executeOnce(String taskKey) {
        timerTaskManager.executeOnce(taskKey);
    }

    /**
     * 任务列表
     */
    @Override
    public List<TimerTaskDto> taskList() {
        return timerTaskManager.taskList(ITimerTaskHandler.class);
    }
}
